﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
using Castle.Core.Resource;
using Castle.Windsor.Configuration.Interpreters;
using FaceSharp.Api.GraphApi;
using FaceSharp.Api.Objects;
using FaceSharp.Api.RestApi;
using Castle.Windsor;

namespace FaceSharp.Api
{
    public class FacebookApi
    {
        private readonly IFacebookCore _facebookCore;
        private GraphBase _graphBase;
        private RestBase _restBase;
        private readonly IWindsorContainer _container;
        
        public FacebookApi()
        {
            if(_container == null) _container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));
            _facebookCore = (IFacebookCore)_container.Resolve(typeof(IFacebookCore));
        }

        public FacebookApi(string accessToken)
        {
            if (_container == null) _container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));
            _facebookCore = (IFacebookCore)_container.Resolve(typeof(IFacebookCore));
            _facebookCore.AccessToken = accessToken;
        }

        public FacebookApi(IFacebookCore facebookCore)
        {
            _facebookCore = facebookCore;
        }

        public string AccessToken
        {
            get { return _facebookCore.AccessToken; }
        }

        public Album Album { get { return new Album(_facebookCore); } }
        public Application Application { get { return new Application(_facebookCore); } }
        public Dashboard Dashboard { get { return new Dashboard(_facebookCore); } }
        public Events Events{ get { return new Events(_facebookCore); } }
        public Feed Feed { get { return new Feed(_facebookCore); } }
        public Insights Insights { get { return new Insights(_facebookCore); } }
        public Likes Likes { get { return new Likes(_facebookCore); } }
        public Links Links { get { return new Links(_facebookCore); } }
        public Notifications Notifications { get { return new Notifications(_facebookCore); } }
        public Page Page { get { return new Page(_facebookCore); } }
        public Photo Photo { get { return new Photo(_facebookCore); } }
        public Places Places { get { return new Places(_facebookCore); } }
        public User User { get { return new User(_facebookCore); } }
        public Groups Groups { get { return new Groups(_facebookCore); } }
        public GraphBase GraphApi { get { return new GraphBase(_facebookCore); } }
        public RestBase RestApi { get { return new RestBase(_facebookCore); } }
    }
}